from django.urls import path, re_path, include
from web.views import account, home, project, wiki, file, setting, issues, dashboard, statistics

urlpatterns = [
    path('register/', account.register, name='register'),  # 注册
    path('login/sms/', account.login_sms, name='login_sms'),  # 短信登录
    path('login/', account.login, name='login'),  # 用户/密码登录
    path('logout/', account.logout, name='logout'),  # 退出登录
    path('img/code/', account.img_code, name='img_code'),  # 生成图片验证码
    path('send/sms/', account.send_sms, name='send_sms'),  # 发送验证码
    path('index/', home.index, name='index'),  # 首页

    # 项目列表
    path('project/list/', project.project_list, name='project_list'),
    re_path(r'^project/star/(?P<project_type>\w+)/(?P<project_id>\d+)/$', project.project_star, name='project_star'),
    re_path(r'^project/unstar/(?P<project_type>\w+)/(?P<project_id>\d+)/$', project.project_unstar,
            name='project_unstar'),

    # 项目管理
    re_path('^manage/(?P<project_id>\d+)/', include([

        path('statistics/', statistics.statistics, name='statistics'),
        re_path('^statistics/priority/$', statistics.statistics_priority, name='statistics_priority'),
        re_path('^statistics/project/user/$', statistics.statistics_project_user, name='statistics_project_user'),

        path('file/', file.file, name='file'),
        path('file/file_delete/', file.file_delete, name='file_delete'),
        path('file/post/', file.file_post, name='file_post'),
        re_path('file/download/(?P<file_id>\d+)/', file.file_download, name='file_download'),
        path('cos/credential/', file.cos_credential, name='cos_credential'),

        path('wiki/', wiki.wiki, name='wiki'),
        path('wiki/add/', wiki.wiki_add, name='wiki_add'),
        re_path('^wiki/del/(?P<wiki_id>\d+)/$', wiki.wiki_del, name='wiki_del'),
        re_path('^wiki/edit/(?P<wiki_id>\d+)/$', wiki.wiki_edit, name='wiki_edit'),
        re_path('^wiki/upload/$', wiki.wiki_upload, name='wiki_upload'),
        path('wiki/catalog/', wiki.wiki_catalog, name='wiki_catalog'),

        path('setting/', setting.setting, name='setting'),
        path('setting/delete', setting.delete, name='delete'),

        path('issues/', issues.issues, name='issues'),
        re_path('^issues/detail/(?P<issues_id>\d+)/$', issues.issues_detail, name='issues_detail'),
        re_path('^issues/record/(?P<issues_id>\d+)/$', issues.issues_record, name='issues_record'),
        re_path('^issues/change/(?P<issues_id>\d+)/$', issues.issues_change, name='issues_change'),
        re_path('^issues/invite/url/$', issues.invite_url, name='invite_url'),

        re_path('dashboard/', dashboard.dashboard, name='dashboard'),
        re_path('^dashboard/issues/chart/$', dashboard.issues_chart, name='issues_chart'),

    ], None)),
    re_path('^issues/invite/join/(?P<code>\w+)/$', issues.invite_join, name='invite_join'),

]
